import { Random } from 'mockjs'

// eslint-disable-next-line no-undef
module.exports = [
    {
        url: '/mock/login',
        method: 'post',
        response: (config) => {
            if (config.body.username === 'admin' && config.body.password === '123456') {
                return {
                    code: 200,
                    data: Random.string(50),
                    message: 'ok'
                }
            } else {
                return {
                    code: 500,
                    data: '',
                    message: '账号或密码出错'
                }
            }
        }
    },
    {
        url: '/mock/info',
        method: 'post',
        response: () => {
            return {
                code: 200,
                data: {
                    id: 1,
                    username: 'admin',
                    nickName: '超级管理员',
                    realName: '超级管理员',
                    createTime: '2023-11-20 10:03:34',
                    updateTime: '2023-11-20 10:03:34',
                    roleAndPermissions: [// 角色和权限
                        'ROLE_ADMIN',
                        'sys:params:edit',
                        'sys:params:del',
                        'playground:test:edit',
                        'playground:test:del',
                        '/system',
                        '/user',
                        '/role',
                        '/menuPermit',
                        '/params',
                        '/playground',
                        '/testView',
                        '/testView/formTest'
                    ],
                },
                message: 'OK'
            }
        }
    },
    {
        url: '/mock/user/getUserInfo',
        method: 'post',
        response: () => {
            return {
                code: 200,
                data: {
                    id: 1,
                    username: 'admin',
                    nickName: '超级管理员',
                    createTime: '2023-11-20 10:03:34',
                    updateTime: '2023-11-20 10:03:34',
                    roleAndPermissions: [// 角色和权限
                        'ROLE_ADMIN',
                        'sys:params:edit',
                        'sys:params:del',
                        'playground:test:edit',
                        'playground:test:del',
                        '/system',
                        '/user',
                        '/role',
                        '/menuPermit',
                        '/params',
                        '/playground',
                        '/testView',
                        '/testView/formTest'
                    ],
                },
                message: 'OK'
            }
        }
    },
    {
        url: '/mock/currentUserMenu',
        method: 'post',
        response: () => {
            return {
                code: 200,
                data: [
                    {
                        id: 3,
                        createTime: '2023-11-20 09:59:07',
                        updateTime: '2023-11-20 09:59:07',
                        permissionName: '系统管理',
                        permissionType: 'MENU',
                        parentId: 0,
                        sort: 2,
                        permissionKey: null,
                        permissionPath: '/system',
                        permissionTopPath: null,
                        icon: null,
                        children: [
                            {
                                id: 5,
                                createTime: '2023-11-20 10:00:58',
                                updateTime: '2023-11-20 10:00:58',
                                permissionName: '用户管理',
                                permissionType: 'MENU',
                                parentId: 3,
                                sort: 1,
                                permissionKey: null,
                                permissionPath: '/user',
                                permissionTopPath: '/system',
                                icon: 'User',
                                children: null
                            },
                            {
                                id: 4,
                                createTime: '2023-11-20 10:00:34',
                                updateTime: '2023-11-20 10:00:34',
                                permissionName: '角色管理',
                                permissionType: 'MENU',
                                parentId: 3,
                                sort: 2,
                                permissionKey: null,
                                permissionPath: '/role',
                                permissionTopPath: '/system',
                                icon: 'Key',
                                children: null
                            },
                            {
                                id: 6,
                                createTime: '2023-11-20 10:01:42',
                                updateTime: '2023-11-20 10:01:42',
                                permissionName: '菜单与权限',
                                permissionType: 'MENU',
                                parentId: 3,
                                sort: 3,
                                permissionKey: null,
                                permissionPath: '/menuPermit',
                                permissionTopPath: '/system',
                                icon: null,
                                children: null
                            },
                            {
                                id: 7,
                                createTime: '2023-11-20 10:02:42',
                                updateTime: '2023-11-20 10:02:42',
                                permissionName: '系统字典',
                                permissionType: 'MENU',
                                parentId: 3,
                                sort: 4,
                                permissionKey: null,
                                permissionPath: '/params',
                                permissionTopPath: '/system',
                                icon: 'Collection',
                                children: null
                            }
                        ]
                    },
                    {
                        id: 17,
                        createTime: '2023-11-20 15:28:39',
                        updateTime: '2023-11-20 15:28:39',
                        permissionName: '广场',
                        permissionType: 'MENU',
                        parentId: 0,
                        sort: 100,
                        permissionKey: null,
                        permissionPath: '/playground',
                        permissionTopPath: null,
                        icon: null,
                        children: [
                            {
                                id: 18,
                                createTime: '2023-11-20 15:29:43',
                                updateTime: '2023-11-20 15:29:43',
                                permissionName: '测试模块',
                                permissionType: 'MENU',
                                parentId: 17,
                                sort: 1,
                                permissionKey: null,
                                permissionPath: '/testView',
                                permissionTopPath: '/playground',
                                icon: null,
                                children: [
                                    {
                                        id: 19,
                                        createTime: '2023-11-20 15:30:13',
                                        updateTime: '2023-11-20 15:30:13',
                                        'createUser': null,
                                        'updateUser': null,
                                        'remarks': null,
                                        'delFlag': 0,
                                        'newRecord': false,
                                        permissionName: '测试表单',
                                        permissionType: 'MENU',
                                        parentId: 18,
                                        sort: 3,
                                        permissionKey: null,
                                        permissionPath: '/testView/formTest',
                                        permissionTopPath: '/playground',
                                        icon: 'isForm',
                                        children: null
                                    }
                                ]
                            }
                        ]
                    }
                ],
                message: 'OK'
            }
        }
    }
]
